//
//  GlossyScene.h
//  Ray Tracer
//
//  Created by Kaila, Ashish on 4/1/13.
//  Copyright (c) 2013 Kaila, Ashish. All rights reserved.
//

#ifndef Ray_Tracer_GlossyScene_h
#define Ray_Tracer_GlossyScene_h

void renderGlossyScene(Raytracer& raytracer,
                       int width,
                       int height,
                       bool enableSpecular)
{
    // Camera parameters.
	Point3D eye(0, 0, 1);
	Vector3D view(0, 0, -1);
	Vector3D up(0, 1, 0);
	double fov = 60;
    
	// Defines a material for shading.
	TextureMaterial gold("Pattern.bmp",
                         Colour(0.3, 0.3, 0.3),
                         51.2,
                         0.005,
                         0.5, //0.005,
                         0.166);
    
    SolidMaterial blue( Colour(0, 0, 0.8), Colour(0, 0, 0.8),
                       Colour(0.8, 0.8, 0.8),
                       10,
                       0.5,
                       0.3,
                       0);
    blue.setGlossFactor(20);
    
    /*
     SolidMaterial chrome(Colour(0.25, 0.25, 0.25), Colour(0.4, 0.4, 0.4),
     Colour(0.774597, 0.774597, 0.774597),
     76.8,
     1,
     1,
     0.166);
     
     
     SolidMaterial chrome(Colour(0.19125, 0.0735, 0.0225),
     Colour(0.7038, 0.27048, 0.0828),
     Colour(0.256777, 0.137622, 0.086014),
     12.8,
     1,
     1,
     0.166);*/
    
    SolidMaterial blue1( Colour(0, 0, 0.8), Colour(0, 0, 0.8),
                        Colour(0.8, 0.8, 0.8),
                        10,
                        0.5,
                        0.3,
                        0);
    
    
    SolidMaterial jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63),
                       Colour(0.316228, 0.316228, 0.316228),
                       12.8,
                       0.5,
                       0.001,
                       1.66);
    
    
	// Defines a point light source.
	raytracer.addLightSource( new PointLight(Point3D(0, 0, 5),
                                             Colour(0.9, 0.9, 0.9) ),
                             enableSpecular);
    
	SceneDagNode* plane = raytracer.addObject( new UnitSquare(&gold));
	SceneDagNode* sphere = raytracer.addObject( new UnitSphere(&blue1));
    SceneDagNode* cylinder = raytracer.addObject( new UnitCylinderShape(&blue));
    
	// Apply some transformations to the unit square.
	double factor1[3] = { 16.0, 16.0, 16.0 };
    double factor2[3] = { 1, 1, 1 };
    double scale[3] = { 2, 2, 2 };
    
    SceneObject* planeObj = plane->obj;
	planeObj->translate(Vector3D(0, 0, -7));
	planeObj->scale(Point3D(0, 0, 0), factor1);
    planeObj->rotate('x', -75);
    
    SceneObject* sphereObj = sphere->obj;
    //sphereObj->scale(Point3D(0, 0, 0), scale);
    sphereObj->translate(Vector3D(-1.5, 0, -2));
    sphereObj->rotate('x', -75);
    
    SceneObject* cylinderObj = cylinder->obj;
    cylinderObj->scale(Point3D(0,0,0), factor2);
    cylinderObj->translate(Vector3D(1.5, 0, -2));
    cylinderObj->rotate('x', -75);
    
	// Render the scene, feel free to make the image smaller for
	// testing purposes.
	raytracer.render(width, height, eye, view, up, fov, "glossy1.bmp");
	
	// Render it from a different point of view.
    Point3D eye2(4, 2, 1);
	Vector3D view2(-4, -2, -6);
	raytracer.render(width, height, eye2, view2, up, fov, "glossy2.bmp");
}

#endif
